// /*备件申请后派单校验 */
// function examineDispatchTWo() {
//     var cbsServiceId = $("#cbsServiceId").val();//服务单id
//     $.ajax({
//         url: "cbsServiceAssignListController.do?SendSingleServiceBusiness",
//         data: {
//             "cbsServiceId": cbsServiceId
//         },
//         cache: false,
//         dataType: 'json',
//         type: 'POST',
//         beforeSend: function () {
//             lockmask(true);
//         },
//         success: function (data) {
//             if (data.success) {
//                 saveDispatchTow(cbsServiceId);
//             } else {
//                 tip(data.msg);
//             }
//         },
//         complete: function () {
//             lockmask(false);
//         }
//     });
// }
//
// /*备件申请后派单*/
// function saveDispatchTow(cbsServiceId) {
//     var contacterName = $("#contacterName").val();
//     var contacterId = $("#contacterId").val();
//     var company = $("#company").val();
//     var contacterEmail = $("#contacterEmail").text();
//     var handleDes = $("#handleDes").val();
//     var assignDes = $("#assignDes").val();
//     var attach = "";
//     $("input:checkbox[id^=att_]:checked").each(function() {
//         attach += this.value + ",";
//     });
//
//     if (company == '' || company == null) {
//         tip("服务商不能为空！");
//         return false;
//     }
//     if (contacterId == '' || contacterId == null) {
//         tip("联系人不能为空！");
//         return false;
//     }
//     if (assignDes == '' || assignDes == null) {
//         tip("派单要求不能为空！");
//         return false;
//     }
//     $.ajax({
//         url: "cbsServiceAssignListController.do?dosaveDispatch",
//         data: {
//             "cbsServiceId": cbsServiceId,
//             "company": company,
//             "contacterId": contacterId,
//             "contacterEmail": contacterEmail,
//             "contacterName": contacterName,
//             "handleDes": handleDes,
//             "attach": attach,
//             "assignDes": assignDes
//         },
//         cache: false,
//         dataType: 'json',
//         type: 'POST',
//         async: false,
//         beforeSend: function () {
//             lockmask(false);
//         },
//         success: function (data) {
//             parent.window.tip(data.msg);
//             frameElement.api.close();
//         },
//         complete: function () {
//             lockmask(false);
//         }
//     });
// }


//服务单编辑页面派单
function saveDispatch() {
    console.info("点击了一次");
    var flag = true;
    var changeStatus = $("#changeStatus").val();
    var type = $("#type").val();
    var company = $("#company").val();
    /*服务单code*/
    var contacterId = $("#contacterId").val();  //维修负责人id
    var contacterName = $("#contacterName").html();
    /*服务单名称*/
    var contacterEmail = $("#contacterEmail").html();
    /*负责人邮箱*/
    var handleDes = $("#handleDes").val();
    /*巴可400处理过程*/
    var assignDes = $("#assignDes").val();
    /*派单要求*/
    var cbsServiceId = $("#cbsServiceId").val();//服务单id
    var authentication = $("#authentication").val();//工程师级别
    var contacterCellPhone = $("#contacterCellPhone").html();//服务商电话
    /*附加任务*/
    var attach = "";
    $("input:checkbox[id^=att_]:checked").each(function () {
        attach += this.value + ",";
    });

    if (company == '' || company == null) {
        tip("服务商不能为空！");
        flag = false;
        return false;
    }
    if (contacterId == '' || contacterId == null) {
        tip("负责人不能为空！");
        flag = false;
        return false;
    }
    if (assignDes == '' || assignDes == null) {
        tip("派单要求不能为空！");
        flag = false;
        return false;
    }

    if (flag) {
        lockmask(true);
        $.ajax({
            url: "cbsServiceAssignListController.do?dosaveDispatch",
            data: {
                "cbsServiceId": cbsServiceId,
                "company": company,
                "contacterId": contacterId,
                "contacterEmail": contacterEmail,
                "handleDes": handleDes,
                "authentication": authentication,
                "attach": attach,
                "contacterName": contacterName,
                "assignDes": assignDes,
                "contacterCellPhone": contacterCellPhone
            },
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                lockmask(false);
                console.info(data.obj);
                closetab("编辑服务单"+data.obj);
                window.top.$("#maintabs").tabs({
                    title: "编辑服务单" + data.obj,
                    onBeforeClose: function (title, index) {
                    }
                });
                window.top.$("#maintabs").tabs('close', "编辑服务单" + data.obj);
                addOneTab("服务单管理", "cbsServiceController.do?cbsService");
            }
        });
    }
}


function cancle(id) {
    $.ajax({
        url: "cbsServiceAssignListController.do?cancleService",
        data: {
            "cbsServiceId": id
        },
        cache: false,
        dataType: 'json',
        type: 'POST',
        beforeSend: function () {
            lockmask(true);
        },
        success: function (data) {
            if (data.success) {
                openwindow('取消', 'cbsServiceController.do?cancel&id=' + id, '', 500, 200);
            } else {
                tip(data.msg);
            }
        },
        complete: function () {
            lockmask(false);
        }
    });

}
